#ifndef CM_ARITH_H_
#define CM_ARITH_H_

extern inline int cm_max(int x, int y)
{
	return x > y ? x : y;
}

extern inline int cm_min(int x, int y)
{
	return x > y ? y : x;
}

extern inline int cm_div(int x, int y)
{
	if (-13 / 5 == -2 && ((x < 0) != (y < 0)) && x % y != 0)
		return x / y - 1;
	else
		return x / y;
}

extern inline int cm_mod(int x, int y)
{
	return x - y * cm_div(x, y);
}

extern inline int cm_ceiling(int x, int y)
{
	return cm_div(x, y) + (x % y != 0);
}
extern inline int cm_floor(int x, int y)
{
	return cm_div(x, y);
}

#endif
